<template>
  <div>
    <div ref="chartColumn" style="width: 100%; height: 320px"></div>
  </div>
</template>
<script>
import * as echarts from "echarts";
export default {
  name: "page",
  mounted() {
    // 在通过mounted调用即可
    this.echartsInit();
  },
  props: {
    dataList: {
      type: Array,
      // default: [],
    },
  },
  methods: {
    //初始化echarts
    echartsInit() {
      let data1 = [];
      let data2 = [];
      let newNum=0
      this.dataList.forEach((e) => {
        if (
          e.attribute != "江苏银行额度计算器-企业查询" &&
          e.attribute != "江苏银行额度计算器-额度测算"
        ) {
          data1.push(e.attribute);
          data2.push(e.num);
        }
        if(e.attribute=='江苏银行额度计算器-企业查询'){
          newNum=newNum+Number(e.num) 
        }
        if(e.attribute=='江苏银行额度计算器-额度测算'){
          newNum=newNum+Number(e.num) 
        }
      });
      data1.push('江苏银行额度计算器')
      data2.push(newNum)
     
    
      let myChart = this.$echarts.init(this.$refs.chartColumn);
      // 指定图表的配置项和数据
      let option = {
        title: {
          x: "2%",
          y: "2%",
          textStyle: {
            fontWeight: 400,
            fontSize: 14,
            color: "#7B8497",
          },
          text: "征像各模块使用率",
        },
        // dataZoom: {
        //   type: "slider",
        //   show: true,
        //   showDetail: false,
        //   height: 14,
        //   xAxisIndex: [0],
        //   start: 0,
        //   // end:dataZoomRange(dataX.length,3),
        //   borderColor: "transparent",
        //   fillerColor: "rgba(119,212,245,0.4)",
        //   backgroundColor: "rgba(119,212,245,0.10)",
        //   borderRadius: 5,
        //   showDataShadow: false,
        //   // handleIcon: '/dataZoomBlock.png',
        //   handleSize: 13.5,
        // },
        backgroundColor: "",
        grid: {
          left: "5%",
          right: "0%",
          top: "15%",
          bottom: "2%",
          containLabel: true,
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "line",
            lineStyle: {
              color: "rgba(50, 216, 205, 1)",
            },
          },
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: 1,
            axisLine: {
              show: false,
            },
            axisLabel: {
              color: "#70798E",
              rotate: 25,
            },
            splitLine: {
              show: true,
            },
            axisTick: {
              show: false,
            },

            data: data1,
          },
        ],
        yAxis: [
          {
            type: "value",
            name: "",
            padding: 5,
            // max: 1000,
            splitLine: {
              show: true,
              lineStyle: {
                color: "rgba(255, 255, 255, 0.2)",
                type: "solid",
              },
            },
            axisLine: {
              show: false,
            },
            axisLabel: {
              show: true,
              margin: 10,
              textStyle: {
                color: "#70798E",
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: "",
            type: "line",
            smooth: true,
            stack: "总量",
            symbolSize: 5,
            showSymbol: false,
            itemStyle: {
              normal: {
                color: "#38D0FB",
                lineStyle: {
                  color: "#38D0FB",
                  width: 2,
                },
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(0,150,255,0.8)",
                    },
                    {
                      offset: 1,
                      color: "rgba(56,208,251,0.2)",
                    },
                  ],
                  false
                ),
              },
            },
            data: data2,
          },
        ],
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },
  },
};
</script>
<style scoped lang="scss"></style>
